<?php

class Inc_Form_Configure extends Zend_Form
{
	public function init()
	{
		// initial form and action
		$this->setAction('/admin/config')->setMethod('post');

		// email for contact form
		$default = new Zend_Form_Element_Text('defaultEmailAddress');
		$default->setLabel('Fallback email address for all operations: ')
				->setOptions(array('size' => 40))
				->setRequired(true)
				->addValidator('EmailAddress')
				->addFilters(array('HtmlEntities', 'StringTrim'));
		
		
		// email for sales
		$sales = new Zend_Form_Element_Text('salesEmailAddress');
		$sales->setLabel('Defaults email address for sales enquiries: ')
		->setOptions(array('size' => 40))
		->setRequired(true)
		->addValidator('EmailAddress')
		->addFilters(array('HtmlEntities', 'StringTrim'));
		
		// for pager in admin panel
		$items = new Zend_Form_Element_Text('itemsPerPage');
		$items->setLabel('Number of items per page in Administrative views: ')
				->setOptions(array('size' => 4))
				->setRequired(true)
				->addValidator('Int')
				->addFilters(array('HtmlEntities', 'StringTrim'));
		
		
		// radio for views sales persone
		$seller = new Zend_Form_Element_Radio('displaySellerInfo');
		$seller->setLabel('Seller name and address visible in public catalog: ')
				->setRequired(true)
				->setMultiOptions(array(
						'1' => 'Yes',
						'2' => 'No'
						));
		
		// radio for log to file
		$log = new Zend_Form_Element_Radio('logEcxeptionsToFile');
		$log->setLabel('Exceptions logged to file: ')
		->setRequired(true)
		->setMultiOptions(array(
				'1' => 'Yes',
				'2' => 'No'
		));
		
		// submit button
		$submit = new Zend_Form_Element_Submit('submit');
		$submit->setLabel('save configuration');
		
		
		$this->addElement($default)
			->addElement($sales)
			->addElement($items)
			->addElement($seller)
			->addElement($log);
		
		
		/*
		 * 		LOGIN GROUP
		*/
		
		$this->addDisplayGroup(
				array('defaultEmailAddress', 'salesEmailAddress', 'itemsPerPage',
						 'displaySellerInfo', 'logEcxeptionsToFile', 'submit'), 'configGroup');
		
		$this->getDisplayGroup('configGroup')
		->setLegend('CONFIGURE');
		
		$this->addElement($submit);
		
	}
}